<template>
  <div id="MyAgentSNew">
    <div class="SQList">
      <van-tabs v-model="active" color="#007DFB" line-width="60px" line-height="4px" title-active-color="#007DFB"
        @click="handleclickto" swipeable>
        <van-tab title="我的待办(旧危改)">
          <ul v-if="listData.length > 0">
            <li v-for="(item, index) in listData" :key="index" @click="listClick(item)">
              <p style="font-weight: bold; height: 30px">
                <span v-if="item.propertyPerson" style="float: left;font-size: 18px;">
                  {{ item.propertyPerson }}
                </span>
              </p>
              <p style="font-size: 14px; color: #848484; height: 30px">
                <span style="float: left">自建房排查编号：{{ item.checkNumber }}</span>
              </p>
              <p style="font-size: 14px; color: #848484; height: 30px">
                <span v-if="item.detailAddress" style="float: left">所属乡镇：{{
                  item.belongCity
                }} {{ item.belongCountry }} {{
  item.belongTown
}} {{ item.villageName }}</span>
                <span style="float: right" v-else>暂无数据</span>
              </p>
              <p style="font-size: 14px; color: #848484; height: 30px">
                <span v-if="item.detailAddress" style="float: left">地址：{{
                  item.detailAddress
                }}</span>
                <span style="float: right" v-else>暂无数据</span>
              </p>
            </li>
          </ul>
          <ul v-else>
            <div style="height: 60vh; text-align: center; padding-top: 20vh">
              <div style="margin-bottom: 10px">
                <img src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/DSF/50.png" />
              </div>
              <div>暂无数据</div>
            </div>
          </ul>
        </van-tab>
        <van-tab title="我的待办(新危改)">
          <ul v-if="listDataKNH.length > 0">
            <li v-for="(item, index) in listDataKNH" :key="index" @click="listClickKNJT(item)">
              <p style="font-weight: bold; height: 30px">
                <span v-if="item.propertyPerson" style="float: left;font-size: 18px;">
                  {{ item.propertyPerson }}
                </span>
              </p>
              <div style="margin: 15px;">
                <p style="font-size: 14px; color: #848484; height: 30px">
                  <span style="float: left">自建房排查编号：{{ item.checkNumber }}</span>
                </p>
                <p style="font-size: 14px; color: #848484; height: 30px">
                  <span style="float: left">房屋类型：{{ item.houseUsageName }}</span>
                </p>
                <p style="font-size: 14px; color: #848484; height: 30px">
                  <span v-if="item.detailAddress" style="float: left">所属乡镇：{{
                    item.belongCity
                  }} {{ item.belongCounty }} {{
  item.belongTown
}} {{ item.villageName }}</span>
                  <span style="float: right" v-else>暂无数据</span>
                </p>
                <p style="font-size: 14px; color: #848484; height: 30px">
                  <span v-if="item.detailAddress" style="float: left">地址：{{
                    item.detailAddress
                  }}</span>
                  <span style="float: right" v-else>暂无数据</span>
                </p>
              </div>

            </li>
          </ul>
          <ul v-else>
            <div style="height: 60vh; text-align: center; padding-top: 20vh">
              <div style="margin-bottom: 10px">
                <img src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/DSF/50.png" />
              </div>
              <div>暂无数据</div>
            </div>
          </ul>
        </van-tab>
      </van-tabs>

    </div>
  </div>
</template>

<script>
import { dangerHouseRemoldList, dangerHouseRemoldListKNH } from "@/utils/api";
import myShenQing1 from "./myShenQing1.vue";
export default {
  name: "MyAgentSNew",
  data() {
    return {
      nowUserCode: "",
      uuss: "",
      uuname: "",
      queryData: "",
      listData: [
      ],
      listDataKNH: [
      
      ],
      active: '1'
    };
  },
  components: {
    myShenQing1
  },
  methods: {
    handleclickto() {
      if (this.active == '0') {
        //一般户
        this.getListData();
      }
      if (this.active == '1') {
        this.getListDataKNH();
      }
    },
    getListData: async function () {
      debugger
      var nowUserCodes = this.nowUserCode ? this.nowUserCode : window.localStorage.getItem('citycode');
      let uscc = "";
      if (nowUserCodes) {
        if (nowUserCodes.substring(0, 12) === "330000000000") {
          nowUserCodes = nowUserCodes.substring(0, 2)
        }

        else if (nowUserCodes.substring(4, 12) === "00000000") {
          nowUserCodes = nowUserCodes.substring(0, 4)
        }

        else if (nowUserCodes.substring(6, 12) === "000000") {
          nowUserCodes = nowUserCodes.substring(0, 6)
        }

        else if (nowUserCodes.substring(9, 12) === "000") {
          nowUserCodes = nowUserCodes.substring(0, 9)
        }
      }
      let formData = JSON.parse(window.localStorage.getItem('FRUSER')) ? JSON.parse(window.localStorage.getItem('FRUSER')) : ''
      if (this.uuss) {
        uscc = this.uuss;
        nowUserCodes = nowUserCodes;
      } else if (formData) {
        nowUserCodes="";
        uscc=formData.uniscid;
      } else {
        uscc = "11";
      }
      var p = {
        "cityCode": nowUserCodes,
        "uscc":uscc,
        "pageNo": 1,
        "pageSize": 10000,
        "type": 1
      }
      const res = await dangerHouseRemoldList(p);
      if (res.data && res.data.data && res.data.data.pageList && res.data.data.pageList.length > 0) {

        this.listData = res.data.data.pageList;
      } else {
        this.listData = [];
      }

    },
    //获取困难户列表信息
    getListDataKNH: async function () {
      var nowUserCodes = this.nowUserCode ? this.nowUserCode : window.localStorage.getItem('citycode');
      let uscc = "";
      if (nowUserCodes) {
        if (nowUserCodes.substring(0, 12) === "330000000000") {
          nowUserCodes = nowUserCodes.substring(0, 2)
        }

        else if (nowUserCodes.substring(4, 12) === "00000000") {
          nowUserCodes = nowUserCodes.substring(0, 4)
        }

        else if (nowUserCodes.substring(6, 12) === "000000") {
          nowUserCodes = nowUserCodes.substring(0, 6)
        }

        else if (nowUserCodes.substring(9, 12) === "000") {
          nowUserCodes = nowUserCodes.substring(0, 9)
        }
      }
      let formData = JSON.parse(window.localStorage.getItem('FRUSER')) ? JSON.parse(window.localStorage.getItem('FRUSER')) : ''
      if (this.uuss) {
        uscc = this.uuss;
        nowUserCodes = nowUserCodes;
      } else if (formData) {
        nowUserCodes = "";
        uscc = formData.uniscid;
      } else {
        uscc = "11";
      }
      var p = {
        "cityCode": nowUserCodes,
        "uscc":uscc,
        "pageNo": 1,
        "pageSize": 10000,
      }
      const res = await dangerHouseRemoldListKNH(p);
      if (res.data && res.data.data && res.data.data.pageList && res.data.data.pageList.length > 0) {

        this.listDataKNH = res.data.data.pageList;
      } else {
        this.listDataKNH = [];
      }
    },
    handleGoto() {
      this.$router.push({
        path: "/myshenQing1",
        query: {
          data: "1",
        },
      });
    },
    listClick(item) {
      this.$router.push({
        path: "/DangerousAppraisalNew",
        query: {
          data: JSON.stringify(item),
          list: this.$route.query.data,
          city: this.$route.query.city
        },
      });
      // console.log(item)
      // // 镇街督办
      // if (item.WF_GUID === '{AFA7FC7F-BDBD-46EA-ABD2-EEF0766096D2}'){
      //   switch (item.NODE_GUID) {
      //     // 鉴定公司
      //     case '{3F794E03-9253-439B-8332-79BCBDE26294}':
      //       this.$router.push({
      //         path: "/DangerousAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break
      //     // 复核鉴定
      //     case '{B4FCC404-5D84-4F9A-B5A2-243ECE2FB244}':
      //       this.$router.push({
      //         path: "/DangerousAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break
      //   }
      // }else{
      //   switch (item.NODE_GUID) {
      //     // （农户）危改申请
      //     case "{5E869057-F0CA-4E87-80D4-9B7FECEAFE9E}":
      //       break;
      //     // 鉴定公司鉴定
      //     case "{C856358A-5B9A-42F0-814D-5BF3F63F5929}":
      //       this.$router.push({
      //         path: "/DangerousAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break;
      //     case "{4A140424-C781-402F-A821-502828EB75DA}":
      //       this.$router.push({
      //         path: "/DangerousAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break;
      //     //  农户申请
      //     case "{7A629180-CF1F-4600-AB4C-33E33ED1E743}":
      //       this.$router.push({
      //         path: "/FarmersRenovation1",
      //         query: {
      //           data: JSON.stringify(item),
      //         },
      //       });
      //       break;
      //     // 农户危房整治
      //     case "{0C256BFE-BC5F-4D63-8AEC-4630EC19F78B}":
      //       if (item.JWFS == "265") {
      //         this.$router.push({
      //           path: "/FarmersRenovation",
      //           query: { data: JSON.stringify(item) },
      //         });
      //       } else {
      //         this.$router.push({
      //           path: "/FarmersRenovation",
      //           query: { data: JSON.stringify(item) },
      //         });
      //       }
      //       break;
      //     //  申请复核鉴定
      //     case "{27EE0E9F-607B-4D25-8934-3693F950C095}":
      //       this.$router.push({
      //         path: "/DangerousAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break;
      //     case "{7A93D2DC-D4B9-4E6A-8DC6-4C2FDFBB9D45}":
      //       this.$router.push({
      //         path: "/DangerousAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break;
      //     //    申请建房补助
      //     case "{B3882940-DD70-48B9-BCDC-544280832103}":
      //       this.$router.push({
      //         path: "/SubsidyApplication",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break;
      //     //  房屋安全鉴定
      //     case "{53BC28FE-1869-4C12-9683-92B5B059D1BB}":
      //       this.$router.push({
      //         path: "/SafetyAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break;
      //     //  农户危房改造
      //     case "{6048BDEF-057A-4080-A536-D9EEE89626D7}":
      //       this.$router.push({
      //         path: "/FarmersRenovation",
      //         query: {
      //           data: JSON.stringify(item),
      //           type: "NHWFGZ",
      //         },
      //       });
      //       break;
      //   }
      // }

    },
    //困难户跳转
    listClickKNJT(item){
      this.$router.push({
        path: "/DangerousAppraisalNewKNH",
        query: {
          data: JSON.stringify(item),
          list: this.$route.query.data,
          city: this.$route.query.city
        },
      });
    },
  },
  updated () {
        this.$nextTick(function () {
            let position = this.$store.state.MyAgentSNew //返回页面取出来
            const content = document.querySelector('#MyAgentSNew')
            content.scrollTop = position
        })
    },
    beforeRouteLeave (to, from, next) {
        const content = document.querySelector('#MyAgentSNew')
        let position = content.scrollTop
        console.log(position)
        this.$store.commit('getMyAgentSNew', position) //离开路由时把位置存起来
        next()
    },
  mounted() {
    debugger
    if (this.$route.query && this.$route.query.data && this.$route.query.city) {
      this.nowUserCode = JSON.parse(this.$route.query.city).citycode ? JSON.parse(this.$route.query.city).citycode : JSON.parse(this.$route.query.city).cityCode;
      this.uuss= JSON.parse(this.$route.query.data).uscc;
      this.uuname = JSON.parse(this.$route.query.data).companyName;
    }
    //
    this.getListData();
    //this.getListDataKNH();
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: '鉴定公司我的待办',
      })
        .then((res) => { })
        .catch((err) => { })
    }
  },
};
</script>

<style scoped lang="scss">
#MyAgentSNew {
  height: 100vh;
  padding: 10px;
  overflow: auto;
  font-family: "Helvetica Neue", Helvetica, STHeiTi, sans-serif;

  ul li {
    padding-top: 10px;
    border-bottom: 1px solid #d2d2d2;
  }
}
</style>

